package com.huichaoliu.stylist.activity;

import com.huichaoliu.app.R;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class StylistMineFragment extends Fragment implements OnClickListener {
	// tools
	Context context;

	// Views
	private View v = null;
	ImageView mine_icon;
	TextView mine_name;
	TextView mine_id;

	RelativeLayout mine_change;
	RelativeLayout mine_aply;
	RelativeLayout mine_aboutus;
	RelativeLayout mine_bank;
	RelativeLayout mine_exist;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		if (v == null) {
			v = inflater.inflate(R.layout.fragment_stylist_mine, container,
					false);
		}
		ViewGroup parent = (ViewGroup) v.getParent();
		if (parent != null) {
			parent.removeView(v);
		}
		context = getActivity();
		init();
		return v;
	}

	private void init() {
		mine_icon = (ImageView) v.findViewById(R.id.mine_icon);
		mine_name = (TextView) v.findViewById(R.id.mine_name);
		mine_id = (TextView) v.findViewById(R.id.mine_id);

		mine_change = (RelativeLayout) v.findViewById(R.id.mine_changeinfo);
		mine_aply = (RelativeLayout) v.findViewById(R.id.mine_moneydetail);
		mine_aboutus = (RelativeLayout) v.findViewById(R.id.mine_connectus);
		mine_bank = (RelativeLayout) v.findViewById(R.id.mine_card);
		mine_exist = (RelativeLayout) v.findViewById(R.id.mine_exist);

		mine_change.setOnClickListener(this);
		mine_aply.setOnClickListener(this);
		mine_aboutus.setOnClickListener(this);
		mine_bank.setOnClickListener(this);
		mine_exist.setOnClickListener(this);

	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.mine_changeinfo:
			Intent intentUpdata = new Intent(context,
					StylistMineUpdataActivity.class);
			startActivity(intentUpdata);
			break;
		case R.id.mine_moneydetail:
			Intent intentAply = new Intent(context,
					MineAplyDetailActivity.class);
			startActivity(intentAply);
			break;
		case R.id.mine_connectus:
			Intent intentUs = new Intent(context, StylistAboutUsActivity.class);
			startActivity(intentUs);
			break;
		case R.id.mine_card:
			Intent intentBank = new Intent(context,
					StylistMineBankActivity.class);
			startActivity(intentBank);
			break;
		case R.id.mine_exist:
			((Activity) context).finish();
			break;

		default:
			break;
		}
	}
}
